package com.billjc.activity.util;

public class Half2FullChange
{
  public static String trim(String str)
  {
    String string = null;
    string = str.trim();
    return string;
  }

  public static String toSBC(String input) {
    char[] c = input.toCharArray();
    for (int i = 0; i < c.length; i++) {
      if (c[i] == ' ') {
        c[i] = '　';
      }
      else if (c[i] < '')
        c[i] = (char)(c[i] + 65248);
    }
    return new String(c);
  }

  public static String[] splitArray(String string, int splitLength, int arraySize) {
    String[] stringArray = new String[arraySize];
    for (int i = 0; i < arraySize; i++) {
      stringArray[i] = "";
    }
    for (int i = 0; i < arraySize; i++) {
      if (string.length() > splitLength) {
        stringArray[i] = string.substring(0, splitLength);
        string = string.substring(splitLength);
      } else if ((string.length() <= splitLength) && (string.length() > 0)) {
        stringArray[i] = string.substring(0, string.length());
        break;
      }
    }

    return stringArray;
  }

  public static void main(String[] args)
  {
    String str = "abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz";
    System.out.println("length:" + str.length());
    String result = toSBC(str);

    System.out.println("Begin" + result + "End");
    System.out.println("length:" + result.length());
    System.out.println("size:" + splitArray(result, 20, 3).length);
    String[] array = splitArray(result, 1, 1);
    for (int i = 0; i < array.length; i++) {
      System.out.println("String[" + i + "]" + array[i]);
    }

    String temp = "  a bc   ";
    System.out.println(temp.length());
    System.out.println(trim(temp).length());
    System.out.println("截取" + temp.substring(0, 3));
    System.out.println("剩下" + temp.substring(3));
  }
}
